home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / hack / 2_3 / fountain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-20  |  8.0 KB  |  346 lines

  1. /*    SCCS Id: @(#)fountain.c    2.3    88/01/21
  2. /* fountain.c  v 1.4.4 */
  3.  
  4. /*
  5.  * Revision 1.4.4  88/02/11  08:31:00  M. Stephenson
  6.  * Implemented "coins" fixes by woodbury@bme.unc.edu
  7.  * Fixed minor bugs.
  8.  *
  9.  * Revision 1.4.3  87/11/25  19:16:00  M. Stephenson
  10.  * Implemented levitation bug fixes.
  11.  *
  12.  * Revision 1.4.3  87/11/25  19:16:00  M. Stephenson
  13.  * Implemented levitation bug fixes.
  14.  *
  15.  * Revision 1.4.2  87/10/19  11:48:00  M. Stephenson
  16.  * Implementation of KJS bug fixes.
  17.  *
  18.  * Revision 1.4.1  87/05/20  11:53:00  M. Stephenson
  19.  * Implementation of KAA bug fixes.
  20.  *
  21.  * Revision 1.4    87/05/04  17:39:00  M. Stephenson
  22.  * Integration of independent modifications
  23.  *
  24.  * Revision 1.3    87/03/02            Eric Backus
  25.  * Rearranged, and dipfountain added
  26.  * 
  27.  * Revision 1.2    87/03/01  13:59:59  gil
  28.  * patches
  29.  * 
  30.  * Revision 1.1    87/02/11  15:14:10  gil
  31.  * Initial revision
  32.  *
  33.  */
  34.  
  35. /* Code for drinking from fountains.   */
  36. /* Scott R. Turner, srt@ucla, 10/27/86 */
  37.  
  38. #include "hack.h"
  39.  
  40. extern struct monst *mkmon_at();
  41. extern struct obj *mkobj_at();
  42. extern char genocided[];
  43.  
  44. #ifdef FOUNTAINS
  45. #define somex() ((int)(rand()%(croom->hx-croom->lx+1))+croom->lx)
  46. #define somey() ((int)(rand()%(croom->hy-croom->ly+1))+croom->ly)
  47.  
  48. dowatersnakes() /* Fountain of snakes! */ {
  49.     register int num = rnd(6);
  50.     if (!index(genocided, 'S')) {
  51.  
  52.         pline("Good Lord!  An endless stream of snakes pours forth!");
  53.         while(num-- > 0) (void) mkmon_at('S',u.ux,u.uy);
  54.     } else
  55.         pline("The fountain bubbles furiously for a moment, then calms.");
  56. }
  57.  
  58. dowaterdemon() /* Water demon */ {
  59. register struct monst *mtmp;
  60.  
  61.     if((mtmp = mkmon_at('&',u.ux,u.uy))) {
  62.         pline("You have unleashed a water demon!");
  63.  
  64.     /* Give those on low levels a (slightly) better chance of survival */
  65.         if ( rnd(100) > (80 + dlevel)) {
  66.         pline("Grateful for his release, he grants you a wish!");
  67.         makewish();
  68.         mondied(mtmp);
  69.         }
  70.     }
  71. }
  72.  
  73. dowaternymph() /* Water Nymph */ {
  74.     register struct monst *mtmp;
  75.     if((mtmp = mkmon_at('N',u.ux,u.uy))) {
  76.  
  77.         pline("You have attracted a water nymph!");
  78.         mtmp->msleep = 0;
  79.     } else
  80.         pline("A large bubble rises to the surface and pops.");
  81. }
  82.  
  83. #include    "mkroom.h"
  84.  
  85. dogushforth() /* Gushing forth in this room */ {
  86. register int num = rnd(10);
  87. register xchar mx,my;
  88. register int tryct = 0;
  89. register int uroom = inroom(u.ux, u.uy);
  90. register struct mkroom *croom = &rooms[uroom];
  91. register int madepool = 0;
  92.  
  93.     if(croom->hx < 0 || has_upstairs(croom) ||
  94.        has_dnstairs(croom))  {
  95.         pline("Your thirst is quenched.");
  96.         return;
  97.     }
  98.     while(num--) {
  99.         do {
  100.         if(++tryct > 200)  {
  101.             if(madepool)
  102.             pline("Water gushes forth from the overflowing fountain!");
  103.             else
  104.             pline("Your thirst is quenched.");
  105.             return;
  106.         }
  107.         mx = somex();
  108.         my = somey();
  109.         } while(nexttodoor(mx,my) || !((mx+my)%2) ||
  110.             (mx == u.ux && my == u.uy) ||
  111.             (IS_POOL(levl[mx][my].typ)));
  112.                
  113.         /* Put a pool at mx, my */
  114.              
  115.         levl[mx][my].typ = POOL;
  116.         atl(mx,my,POOL_SYM);
  117.         madepool = 1;
  118.     }
  119.  
  120.     pline("Water gushes forth from the overflowing fountain!");
  121. }
  122.  
  123. dofindgem() /* Find a gem in the sparkling waters. */ {
  124.  
  125.     if (!Blind) pline("You spot a gem in the sparkling waters!");
  126.     mkobj_at('*',u.ux,u.uy);
  127. }
  128.  
  129. dryup(){
  130.     if (!rn2(3) && (levl[u.ux][u.uy].typ == FOUNTAIN)) {
  131.         pline("The fountain dries up!");
  132.         levl[u.ux][u.uy].typ = ROOM;
  133.         if(Invis) newsym(u.ux, u.uy);
  134.     }
  135. }
  136.  
  137. drinkfountain() {
  138.  
  139.     /* What happens when you drink from a fountain? */
  140.     register int fate = rnd(30);
  141.  
  142.     if(Levitation)     pline("You are floating high above the fountain.");
  143.     else if (fate < 10) {
  144.         pline("The cool draught refreshes you.");
  145.         lesshungry(rnd(10));
  146.     } else {
  147.         switch (fate) {
  148.  
  149.         case 20: /* Foul water */
  150.  
  151.             pline("The water is foul!  You gag and vomit.");
  152.             morehungry(rnd(20)+10);
  153.             if(Sick)  {
  154.                 Sick = 0;
  155.                 pline("What a relief!");
  156.             }
  157.             break;
  158.  
  159.         case 21: /* Poisonous */
  160.  
  161.             pline("The water is contaminated!");
  162.             if (Poison_resistance) {
  163.                pline("Perhaps it is run off from the nearby orange farm.");
  164.                losehp(rnd(4),"unrefrigerated orange juice");
  165.                break;
  166.             }
  167.             losestr(rn1(4,3));
  168.             losehp(rnd(10),"contaminated water");
  169.             break;
  170.     
  171.         case 22: /* Fountain of snakes! */
  172.             dowatersnakes();
  173.             break;
  174.  
  175.         case 23: /* Water demon */
  176.             dowaterdemon();
  177.             break;
  178.  
  179.         case 24: /* Curse an item... */ {
  180.             register struct obj *obj;
  181.  
  182.             pline("This water's no good!");
  183.             morehungry(rnd(20)+10);
  184.             for(obj = invent; obj ; obj = obj->nobj)
  185.                 if (!rn2(5))    obj->cursed++;
  186.             break;
  187.             }
  188.              
  189.         case 25: /* See invisible */
  190.  
  191.             pline("You see an image of someone stalking you.");
  192.             pline("But it disappears.");
  193.             HSee_invisible |= INTRINSIC;
  194.             break;
  195.  
  196.         case 26: /* See Monsters */ {
  197.             register struct monst *mtmp;
  198.  
  199.               if(!fmon) pline("You feel oddly disturbed.");
  200.               else {
  201.                 cls();
  202.                 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  203.                 if(mtmp->mx > 0)
  204.                     at(mtmp->mx,mtmp->my,mtmp->data->mlet);
  205.                 prme();
  206.                 pline("You sense the presence of monsters.");
  207.                 more();
  208.                 docrt();
  209.               }
  210.             }
  211.             break;
  212.  
  213.         case 27: /* Find a gem in the sparkling waters. */
  214.             dofindgem();
  215.             break;
  216.  
  217.         case 28: /* Water Nymph */
  218.             dowaternymph();
  219.             break;
  220.  
  221.         case 29: /* Scare */ {
  222.             register struct monst *mtmp;
  223.  
  224.             pline("This water gives you bad breath!");
  225.             for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 
  226.                 mtmp->mflee = 1;
  227.             }
  228.             break;
  229.  
  230.         case 30: /* Gushing forth in this room */
  231.             dogushforth();
  232.             break;
  233.         default:
  234.             break;
  235.         }
  236.     }
  237.     dryup();
  238. }
  239.  
  240. dipfountain(obj)
  241. register struct obj *obj;
  242. {
  243.     register int fate = rnd(30);
  244.  
  245.     if(Levitation)     pline("You are floating high above the fountain.");
  246.     else if(fate<10)
  247.         if(!obj->rustfree &&
  248.             /* Only swords affected here */
  249.             (obj->otyp == LONG_SWORD ||
  250.             obj->otyp == KATANA ||
  251.             obj->otyp == BROAD_SWORD ||
  252.             obj->otyp == SHORT_SWORD ||
  253.             obj->otyp == TWO_HANDED_SWORD)) {
  254.             if(obj->spe > -6) {
  255.                 pline("Your weapon rusts somewhat.");
  256.                 obj->spe--;
  257.             } else pline("Your weapon looks quite rusted.");
  258.         } else pline("Well, it looks wet now.");
  259.     else if(fate<14)
  260.         if(obj->otyp == LONG_SWORD
  261. #ifndef RPH
  262.            && !strcmp(ONAME(obj), "Excalibur")
  263. #endif
  264.         ) {
  265.             /* The lady of the lake acts! - Eric Backus */
  266.             /* Be *REAL* nice to him */
  267.     pline("A murky hand from the depths reaches up to bless the sword.");
  268.     pline("As the hand retreats, the fountain disappears!");
  269. #ifndef RPH
  270.             if(obj->spe < 5) obj->spe = 5;
  271. #else
  272.             /* otherwise +rnd(10) / +5 "Super"sword */
  273.             oname(obj, "Excalibur");
  274. #endif
  275. #ifdef KAA
  276.             obj->dknown = 1;    /* blessed */
  277. #endif
  278.             obj->cursed = 0;
  279.             obj->rustfree = 1;
  280.             levl[u.ux][u.uy].typ = ROOM;
  281.             if(Invis) newsym(u.ux, u.uy);
  282.             return(0);
  283.         } else pline ("Well, it looks wet now.");
  284.     else {
  285.         switch (fate) {
  286.         case 16: /* Curse the item */
  287.             pline("Well, it looks wet now.");
  288.             obj->cursed = 1;
  289.             break;
  290.         case 17:
  291.         case 18:
  292.         case 19:
  293.         case 20: /* Uncurse the item */
  294.             if(obj->cursed) {
  295.                 pline("The water glows for a moment.");
  296.                 obj->cursed = 0;
  297.             } else {
  298.                 pline("A feeling of loss comes over you.");
  299.             }
  300.             break;
  301.         case 21: /* Water Demon */
  302.             dowaterdemon();
  303.             break;
  304.         case 22: /* Water Nymph */
  305.             dowaternymph();
  306.             break;
  307.         case 23: /* An Endless Stream Of Snakes */
  308.             dowatersnakes();
  309.             break;
  310.         case 24: /* Find a gem */
  311.             dofindgem();
  312.             break;
  313.         case 25: /* Water gushes forth */
  314.             dogushforth();
  315.             break;
  316.         case 26: /* Strange feeling */
  317.             pline("A strange tingling runs up your arm.");
  318.             break;
  319.         case 27: /* Strange feeling */
  320.             pline("You feel a sudden chill.");
  321.             break;
  322.         case 28: /* Strange feeling */
  323.         pline("An urge to take a bath overwhelms you.");
  324.             if (u.ugold > 10) {
  325.                      u.ugold -= somegold()/10;
  326.               pline("You lost some of your gold in the fountain!");
  327.              }
  328.             break;
  329.         case 29: /* You see coins */
  330.  
  331.         /* We make fountains have more coins the closer you are to the
  332.          * surface.  After all, there will have been more people going
  333.          * by.  Just like a shopping mall!  Chris Woodbury  */
  334.  
  335.             mkgold((long)(rnd((MAXLEVEL-dlevel)*2)+5),u.ux,u.uy);
  336.         pline("Far below you, you see coins glistening in the water.");
  337.             break;
  338.         default:
  339.             break;
  340.         }
  341.     }
  342.     dryup();
  343.     return(0);
  344. }
  345. #endif
  346.